package com.maxmlr.mybatisplus.common.base;

import com.maxmlr.mybatisplus.common.resut.ResultBean;
import com.maxmlr.mybatisplus.common.resut.ResultPageBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 
 * @Package com.maxmlr.common.base
 * @ClassName BaseController
 * @Description 控制器基类
 * @author max
 * @since 2018年12月15日 下午6:06:33 
 * @version 1.0
 * @Copyright Copyright (c) 2018: www.maxmlr.com.
 */
public abstract class BaseController {
    private static Logger logger = LoggerFactory.getLogger(BaseController.class);
    
    protected ResultBean getResultBean(String code, String msg) {
		return new ResultBean(code, msg);
	}
    
    protected ResultPageBean getResultPageBean(String code, String msg) {
		return new ResultPageBean(code, msg);
	}

    /**
     * 计算当前页数
     *
     * @param start
     *            偏移量
     * @param length
     *            页大小
     * @return pageNo 当前页数
     */
    public static Integer getPageNo(Integer start, Integer length) {
        Integer pageNo = 1;
        if (++start > 1) { 
            pageNo = start / length;
            if (start % length > 0)
                pageNo++;
        }
        return pageNo;
    }

}
